import router from '@/router'

export function getToken() {
  // const token = localStorage.getItem('token') || false
  // return token
  // return true
  return false
}

/**
 * 根据当前路径获取上级节点数据集合
 * @param {String} path 当前url
 * @param {Array<String>} openedKeys 默认展开的上级节点数组
 * @returns {Array<String>}
 */
export const getParentPaths = (path, openedKeys = []) => {
  const recur = (router, path) => {
    for (let item of router) {
      if (item.path === path) {
        openedKeys = item.parentPaths
        return openedKeys
      } else if (item.children && item.children.length > 0) {
        recur(item.children, path)
      }
    }
  }
  recur(router, path)
  return openedKeys
}